var _listFriendsView;

app.Views.ListFriendsView = Backbone.View.extend({
	
	id:"listFriends",
	
	initialize:function () {
		
		_listFriendsView = this;
		
		this.template = _.template(tpl.get('listFriends'));
		this.delegateEvents(); 
		
        return this;	
    },	

    render:function (eventName) {
		
		$(this.el).html(this.template());
		
		this.buildList(); 		 
		   
        return this;
    },
	
	buildList:function(){
		
		var friendsGroupSelector = $(this.el).find("#friends-group");
		
		_.each(this.collection.models, function (data) {
			
			var friend = new app.Views.ItemFriendsView({model:data});
			friendsGroupSelector.append(friend.render().el);
			
		});	
		
		
	},
	
	destroy:function(){
	
		$(this.el).empty();
		
	}

});